package com.fowo.api.sys.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fowo.api.common.util.StringUtils;
import com.fowo.api.sys.entity.SysTaskLog;
import com.fowo.api.sys.mapper.SysTaskLogMapper;
import com.fowo.api.sys.model.SysTaskLogSearch;
import com.fowo.api.sys.service.SysTaskLogService;
import org.springframework.stereotype.Service;

@Service
public class SysTaskLogServiceImpl
        extends ServiceImpl<SysTaskLogMapper, SysTaskLog>
        implements SysTaskLogService {

    @Override
    public Page<SysTaskLog> searchPage(SysTaskLogSearch search) {
        return baseMapper.searchPage(search.toPage(), search);
    }

    @Override
    public boolean create(SysTaskLog log) {
        log.setFullMessage(log.getMessage());
        if (log.getMessage().length() > 500) {
            log.setMessage(StringUtils.ellipsis(log.getMessage(), 500));
        }
        return super.save(log);
    }
}
